<?php

// require_once 'Zend/Gdata/Extension.php';
require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rats_Extension_OutputParams extends Raws_Extension_Params
{

    // protected $_rootNamespace = 'raws';
    // protected $_rootElement = 'params';
 
    protected $_id = null;
    protected $_name = null;
    protected $_description = null;
    protected $_method = null;
    protected $_base_uri = null;
    protected $_public_uri = null;
    protected $_cdn = null;
    protected $_allow_overwrite = null;
    protected $_max_size = null;
    protected $_params = null;

    public function __construct($name = null, $description = null, $method = null, $base_uri = null, $public_uri = null) 
    {
        // foreach (Rats::$namespaces as $nsPrefix => $nsUri) {
        //     $this->registerNamespace($nsPrefix, $nsUri);
        // }
        parent::__construct();
        $this->_name = $name;
        $this->_description = $description;
        $this->_method = $method;
        $this->_base_uri = $base_uri;
        $this->_public_uri = $public_uri;
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = null)
    {
        $element = parent::getDOM($doc);
        if ($this->_id !== null) {
            $element->appendChild($this->_id->getDOM($element->ownerDocument));
        }
        if ($this->_name !== null) {
            $element->appendChild($this->_name->getDOM($element->ownerDocument));
        }
        if ($this->_description !== null) {
            $element->appendChild($this->_description->getDOM($element->ownerDocument));
        }
        if ($this->_method !== null) {
            $element->appendChild($this->_method->getDOM($element->ownerDocument));
        }
        if ($this->_base_uri !== null) {
            $element->appendChild($this->_base_uri->getDOM($element->ownerDocument));
        }
        if ($this->_public_uri !== null) {
            $element->appendChild($this->_public_uri->getDOM($element->ownerDocument));
        }
        if ($this->_cdn !== null) {
            $element->appendChild($this->_cdn->getDOM($element->ownerDocument));
        }
        if ($this->_allow_overwrite !== null) {
            $element->appendChild($this->_allow_overwrite->getDOM($element->ownerDocument));
        }
        if ($this->_max_size !== null) {
            $element->appendChild($this->_max_size->getDOM($element->ownerDocument));
        }
        if ($this->_params !== null) {
            $element->appendChild($this->_params->getDOM($element->ownerDocument));
        }
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'id'; 
                $id = new Rats_Extension_Name();
                $id->transferFromDOM($child);
                $this->_id = $id;
                break;
            case $this->lookupNamespace('raws') . ':' . 'name'; 
                $name = new Rats_Extension_Name();
                $name->transferFromDOM($child);
                $this->_name = $name;
                break;
            case $this->lookupNamespace('raws') . ':' . 'description'; 
                $description = new Rats_Extension_Description();
                $description->transferFromDOM($child);
                $this->_description = $description;
                break;
            case $this->lookupNamespace('raws') . ':' . 'method'; 
                $method = new Rats_Extension_Method();
                $method->transferFromDOM($child);
                $this->_method = $method;
                break;
            case $this->lookupNamespace('raws') . ':' . 'base_uri'; 
                $base_uri = new Rats_Extension_BaseUri();
                $base_uri->transferFromDOM($child);
                $this->_base_uri = $base_uri;
                break;
            case $this->lookupNamespace('raws') . ':' . 'public_uri'; 
                $public_uri = new Rats_Extension_PublicUri();
                $public_uri->transferFromDOM($child);
                $this->_public_uri = $public_uri;
                break;
            case $this->lookupNamespace('raws') . ':' . 'cdn'; 
                $cdn = new Rats_Extension_Cdn();
                $cdn->transferFromDOM($child);
                $this->_cdn = $cdn;
                break;
            case $this->lookupNamespace('raws') . ':' . 'allow_overwrite'; 
                $allow_overwrite = new Rats_Extension_AllowOverwrite();
                $allow_overwrite->transferFromDOM($child);
                $this->_allow_overwrite = $allow_overwrite;
                break;
            case $this->lookupNamespace('raws') . ':' . 'max_size'; 
                $max_size = new Rats_Extension_MaxSize();
                $max_size->transferFromDOM($child);
                $this->_max_size = $max_size;
                break;
            case $this->lookupNamespace('raws') . ':' . 'params'; 
                $params = new Rats_Extension_Params();
                $params->transferFromDOM($child);
                $this->_params = $params;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }


    public function getId()
    {
        return $this->_id;
    }

    public function setId($value)
    {
        $this->_id = $value;
        return $this;
    }
    
    public function getName()
    {
        return $this->_name;
    }

    public function setName($value)
    {
        $this->_name = $value;
        return $this;
    }

    public function getDescription()
    {
        return $this->_description;
    }

    public function setDescription($value)
    {
        $this->_description = $value;
        return $this;
    }

    public function getMethod()
    {
        return $this->_method;
    }

    public function setMethod($value)
    {
        $this->_method = $value;
        return $this;
    }

    public function getBaseUri()
    {
        return $this->_base_uri;
    }

    public function setBaseUri($value)
    {
        $this->_base_uri = $value;
        return $this;
    }

    public function getPublicUri()
    {
        return $this->_public_uri;
    }

    public function setPublicUri($value)
    {
        $this->_public_uri = $value;
        return $this;
    }

    public function getCdn()
    {
        return $this->_cdn;
    }

    public function setCdn($value)
    {
        $this->_cdn = $value;
        return $this;
    }

    public function getAllowOverwrite()
    {
        return $this->_allow_overwrite;
    }

    public function setAllowOverwrite($value)
    {
        $this->_allow_overwrite = $value;
        return $this;
    }

    public function getMaxSize()
    {
        return $this->_max_size;
    }

    public function setMaxSize($value)
    {
        $this->_max_size = $value;
        return $this;
    }

    public function getParams()
    {
        return $this->_params;
    }

    public function setParams($value)
    {
        $this->_params = $value;
        return $this;
    }

}
